From c7605b79d7312eab1af65fffbd42e2775b3e5e06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:07:58 +0000 Subject: [PATCH 001/138] Auto-generated commit a356e56fc19709396066448f36b8b409634c691f --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 321 ++++++ index.d.ts | 180 ++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 69 ++ stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3774 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..3d87da0 --- /dev/null +++ b/README.md @@ -0,0 +1,321 @@ + + +# Typed Arrays + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a typed array. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs'; +``` + +#### typedarray( \[dtype] ) + +Creates a [typed array][mdn-typed-array] having a specified data type `dtype`. + +```javascript +var arr = typedarray(); +// 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` + +By default, the output [typed array][mdn-typed-array] data type is `float64`. To specify an alternative data type, provide a `dtype` argument. + +```javascript +var arr = typedarray( 'int32' ); +// returns +``` + +#### typedarray( length\[, dtype] ) + +Returns a [typed array][mdn-typed-array] having a specified `length`. + +```javascript +var arr1 = typedarray( 5 ); +// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] + +var arr2 = typedarray( 5, 'uint8' ); +// returns [ 0, 0, 0, 0, 0 ] +``` + +#### typedarray( typedarray\[, dtype] ) + +Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. + +```javascript +var arr1 = typedarray( [ 5.0, -3.0, 2.0 ] ); +// returns [ 5.0, -3.0, 2.0 ] + +var arr2 = typedarray( arr1 ); +// returns [ 5.0, -3.0, 2.0 ] + +var arr3 = typedarray( arr1, 'int32' ); +// returns [ 5, -3, 2 ] +``` + +#### typedarray( obj\[, dtype] ) + +Creates a [typed array][mdn-typed-array] from an array-like object or iterable. + +```javascript +var arr1 = typedarray( [ 0.5, 0.5, 0.5 ] ); +// returns [ 0.5, 0.5, 0.5 ] + +var arr2 = typedarray( [ 0.5, 0.5, 0.5 ], 'float32' ); +// returns [ 0.5, 0.5, 0.5 ] +``` + +If `dtype` is complex number data type and an array-like object contains interleaved real and imaginary components, the array-like object must have a length which is a multiple of two. + +#### typedarray( buffer\[, byteOffset\[, length]]\[, dtype] ) + +Returns a [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 arr1 = typedarray( buf ); +// returns [ 0.0, 0.0, 0.0, 0.0 ] + +var arr2 = typedarray( buf, 'float32' ); +// returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] + +var arr3 = typedarray( buf, 16 ); +// returns [ 0.0, 0.0 ] + +var arr4 = typedarray( buf, 16, 'float32' ); +// returns [ 0.0, 0.0, 0.0, 0.0 ] + +var arr5 = typedarray( buf, 16, 1 ); +// returns [ 0.0 ] + +var arr6 = typedarray( buf, 10, 4, 'int16' ); +// returns [ 0, 0, 0, 0 ] +``` + +
+ + + + + +
+ +## Notes + +- When providing a complex number array, if `dtype` is unspecified or the specified data type is not a complex number data type, the returned array contains interleaved real and imaginary components. + +
+ + + + + +
+ +## 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..0521bde --- /dev/null +++ b/index.d.ts @@ -0,0 +1,180 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 + +// tslint:disable:unified-signatures + +/// + +import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array-buffer' ); + +/** +* Creates a typed array. +* +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var arr = typedarray(); +* // returns +* +* @example +* var arr = typedarray( 'float32'); +* // returns +*/ +declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param length - typed array length +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var arr = typedarray( 2 ); +* // returns [ 0.0, 0.0 ] +* +* @example +* var arr = typedarray( 2, 'float32' ); +* // returns [ 0.0, 0.0 ] +*/ +declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param typedarray - typed array from which to generate another typed array +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var arr = typedarray( new Float64Array( 2 ) ); +* // returns [ 0.0, 0.0 ] +* +* @example +* var arr = typedarray( new Float64Array( 2 ), 'float32' ); +* // returns [ 0.0, 0.0 ] +* +* @example +* var arr1 = typedarray( [ 5, 3 ], 'int32' ); +* var arr2 = typedarray( arr1 ); +* // returns [ 5.0, 3.0 ] +* +* @example +* var arr1 = typedarray( [ 5, 3 ], 'int32' ); +* var arr2 = typedarray( arr1, 'uint32' ); +* // returns [ 5, 3 ] +*/ +declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param obj - array-like object or iterable from which to generate a typed array +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var arr = typedarray( [ 0.5, 0.5 ] ); +* // returns [ 0.5, 0.5 ] +* +* @example +* var arr = typedarray( [ 5, -3 ], 'int32' ); +* // returns [ 5, -3 ] +*/ +declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param buffer - underlying ArrayBuffer +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = typedarray( buf ); +* // returns [ 0.0, 0.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = typedarray( buf, 'float32' ); +* // returns [ 0.0, 0.0, 0.0, 0.0 ] +*/ +declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param buffer - underlying ArrayBuffer +* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = typedarray( buf, 8 ); +* // returns [ 0.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = typedarray( buf, 8, 'float32' ); +* // returns [ 0.0, 0.0 ] +*/ +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a typed array. +* +* @param buffer - underlying ArrayBuffer +* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param dtype - data type (default: 'float64') +* @returns typed array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = typedarray( buf, 8, 2 ); +* // returns [ 0.0, 0.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = typedarray( buf, 8, 2, 'int32' ); +* // returns [ 0, 0 ] +*/ +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + + +// EXPORTS // + +export = typedarray; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c8bb1e7 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var n=e.isPrimitive,d=t,m=s,o=r,l=i,p=d("complex64"),a=d("complex128");var j=function(){var e,t,s,r;if(t=(e=arguments.length)&&n(arguments[e-1])?arguments[e-=1]:"float64",null===(s=d(t)))throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return e<=0?new s(0):1===e?((r=arguments[0])instanceof p?r=o(r,0):r instanceof a&&(r=m(r,0)),new s(r)):2===e?new s(arguments[0],arguments[1]):new s(arguments[0],arguments[1],arguments[2])};export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e14d4d --- /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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isString","require$$0","isPrimitive","ctors","require$$1","reinterpret128","require$$2","reinterpret64","require$$3","format","require$$4","Complex64Array","Complex128Array","lib","nargs","dtype","ctor","arg","arguments","length","TypeError"],"mappings":";;ucAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAQC,EACRC,EAAiBC,EACjBC,EAAgBC,EAChBC,EAASC,EAKTC,EAAiBR,EAAO,aACxBS,EAAkBT,EAAO,cA+H7B,IClCAU,EDNA,WACC,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJnB,EAAUkB,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOb,EAAOY,IAEb,MAAM,IAAIK,UAAWX,EAAQ,sEAAuEM,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGP,EACnBM,EAAMV,EAAeU,EAAK,GACfA,aAAeL,IAC1BK,EAAMZ,EAAgBY,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a176b1f --- /dev/null +++ b/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/array-typed", + "version": "0.0.0", + "description": "Create a typed array.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-typed.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", + "complex64array", + "complex128array", + "float64", + "double", + "precision", + "double-precision", + "single", + "float", + "single-precision", + "float32", + "ieee754", + "integer", + "int32", + "signed", + "unsigned", + "uint32", + "int16", + "uint16", + "int8", + "uint8", + "uint8c", + "clamped", + "short", + "long", + "complex", + "cmplx" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..018b434 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 373e8038b10f3167ed3f863d038507e2a6dba6a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 22:54:21 +0000 Subject: [PATCH 002/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From f246f96b3cd83cf4223cd4b6d95b820e3fa75a14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:10:32 +0000 Subject: [PATCH 003/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c8bb1e7..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var n=e.isPrimitive,d=t,m=s,o=r,l=i,p=d("complex64"),a=d("complex128");var j=function(){var e,t,s,r;if(t=(e=arguments.length)&&n(arguments[e-1])?arguments[e-=1]:"float64",null===(s=d(t)))throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return e<=0?new s(0):1===e?((r=arguments[0])instanceof p?r=o(r,0):r instanceof a&&(r=m(r,0)),new s(r)):2===e?new s(arguments[0],arguments[1]):new s(arguments[0],arguments[1],arguments[2])};export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e14d4d..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isString","require$$0","isPrimitive","ctors","require$$1","reinterpret128","require$$2","reinterpret64","require$$3","format","require$$4","Complex64Array","Complex128Array","lib","nargs","dtype","ctor","arg","arguments","length","TypeError"],"mappings":";;ucAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAQC,EACRC,EAAiBC,EACjBC,EAAgBC,EAChBC,EAASC,EAKTC,EAAiBR,EAAO,aACxBS,EAAkBT,EAAO,cA+H7B,IClCAU,EDNA,WACC,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJnB,EAAUkB,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOb,EAAOY,IAEb,MAAM,IAAIK,UAAWX,EAAQ,sEAAuEM,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGP,EACnBM,EAAMV,EAAeU,EAAK,GACfA,aAAeL,IAC1BK,EAAMZ,EAAgBY,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 018b434..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7101be3b095f2c911cfeb13b602e1117e2da3569 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:11:18 +0000 Subject: [PATCH 004/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 48 files changed, 2721 insertions(+), 6227 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.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 be6ec2e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:53:36.495Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..835157f --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fb3f272 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..91f88d3 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 934f29e452d9498cb2a3e1fd9bfe8f61b9d9dad6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:27:31 +0000 Subject: [PATCH 005/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 958d76ddef525aed4df0f65ae10125c01045723e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:18:57 +0000 Subject: [PATCH 006/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 835157f..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fb3f272..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 91f88d3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e7fa2830d103bef1add6be7171f350ecb99a1450 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:19:47 +0000 Subject: [PATCH 007/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 48 files changed, 2721 insertions(+), 6227 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.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 e3dd622..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:42:59.666Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..835157f --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fb3f272 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..e470819 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 11f9762c8cda68db39b199f9ab9f3c868e6bdcff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:44:35 +0000 Subject: [PATCH 008/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 2f3f5a33453b5a61813723b893985c01ddcbc67e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:23:45 +0000 Subject: [PATCH 009/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 835157f..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fb3f272..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e470819..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 80e653a166217945cbed60c42150dd71439d1fe5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:24:46 +0000 Subject: [PATCH 010/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 47 files changed, 2721 insertions(+), 6192 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.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 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..835157f --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fb3f272 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..67367f5 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 08fd1368bfec325b857f0e895e07e88baa79dd21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:58:23 +0000 Subject: [PATCH 011/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 269e1a16d0981df2d9244446008d5b3156eb33b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:44:19 +0000 Subject: [PATCH 012/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 835157f..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fb3f272..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;+dA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 67367f5..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1aeac4e5b72e25a33cebb82d5b5d9d1d0953a697 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:45:12 +0000 Subject: [PATCH 013/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 48 files changed, 2721 insertions(+), 6266 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.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 a713c40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:45:07.056Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..55c386b --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..c1bd3c3 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 36e6cc7969fc651553cba953e7ea8be0a14ddcdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:50:19 +0000 Subject: [PATCH 014/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From af69adb225915f7c5dcd63375f98f5ae9a7ed9b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:14:53 +0000 Subject: [PATCH 015/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 55c386b..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c1bd3c3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d648915707340dc11a5110fbbfc52f3fd0b58775 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:15:36 +0000 Subject: [PATCH 016/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 48 files changed, 2721 insertions(+), 6282 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.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 f2880a1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:45:24.147Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..55c386b --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..d324e19 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 260d2c77e54ec3544623e9db05fb9b35c0418c20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:19:01 +0000 Subject: [PATCH 017/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From acb70e51c958447ce0818431a7728613efcc1445 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:16:01 +0000 Subject: [PATCH 018/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 55c386b..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d324e19..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ab61f45b1f5af50fce69ee8129f0a782f3cab941 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:16:59 +0000 Subject: [PATCH 019/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 -- docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 -- package.json | 73 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1451 ----------- 48 files changed, 2721 insertions(+), 6282 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.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 3817c1c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:13:13.458Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..55c386b --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..23bcca4 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 135b453df489b835dd3f7dcc1fe84bea235ea08c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:03:12 +0000 Subject: [PATCH 020/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 5d9a873f8730d20819f95a69ff4799bbb2bc1271 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:09:35 +0000 Subject: [PATCH 021/138] Remove files --- index.d.ts | 180 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2874 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 55c386b..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 23bcca4..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 689eaeacd8451d5fa543343653ad32f81ca411ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:10:26 +0000 Subject: [PATCH 022/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1451 -------- 48 files changed, 4076 insertions(+), 6282 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.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 2af1792..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:58:23.854Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1d5af83 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..85d2eac --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 186a9564629a214abb050c100378aa579cb39c7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:42:37 +0000 Subject: [PATCH 023/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index f4a8074..c39f0c7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 60dcf460ad11eb2fbd24f49505304b3bee11795e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:43:16 +0000 Subject: [PATCH 024/138] Remove files --- index.d.ts | 180 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4229 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1d5af83..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 85d2eac..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e858e3076a35f8d5d4873ffed585f57d8fc94d56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:44:18 +0000 Subject: [PATCH 025/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1451 -------- 48 files changed, 4076 insertions(+), 6303 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.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 1db1b5e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T23:00:58.514Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1d5af83 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index c39f0c7..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..8a34e8f --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 7a543f50333e5fa046b812d2653da42b39e9c98c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:50:19 +0000 Subject: [PATCH 026/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index b5a2c44..2f768be 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From cf2849cf6582412a17c9585dacb316773181a937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 15:46:04 +0000 Subject: [PATCH 027/138] Remove files --- index.d.ts | 180 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4229 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1d5af83..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) 2018 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 ctors from '@stdlib/array-typed-ctors' ;\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128' ;\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8a34e8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From bfd9c5ae106230d663255f6e9384385079329d0b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 15:47:06 +0000 Subject: [PATCH 028/138] 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 | 55 +- benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1451 -------- 48 files changed, 4076 insertions(+), 6308 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.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 fdb2ecd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:49:25.147Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0fd6f7a --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..77806b6 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 2f768be..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..479c12c --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From d63ed539ad1d03c0b76b1abaa3a5a44cb9f03926 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:17:39 +0000 Subject: [PATCH 029/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..56aa41d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '01B2k', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 8e86959..e49b13b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From f80863a25882ba3f3361842f4372e06b779eb974 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:11:12 +0000 Subject: [PATCH 030/138] Remove files --- index.d.ts | 180 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4229 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0fd6f7a..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 77806b6..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 479c12c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From de32664a382db95d37a515b67717aa3b64eca304 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:12:04 +0000 Subject: [PATCH 031/138] 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 | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1451 ----- 48 files changed, 6209 insertions(+), 6319 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.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 3561b03..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:29:46.626Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 204c19c..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/typed" -click B href "https://github.com/stdlib-js/array-typed/tree/main" -click C href "https://github.com/stdlib-js/array-typed/tree/production" -click D href "https://github.com/stdlib-js/array-typed/tree/esm" -click E href "https://github.com/stdlib-js/array-typed/tree/deno" -click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 dcd6eb8..0521bde 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2601140 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..77806b6 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 56aa41d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '01B2k', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index e49b13b..b55cb88 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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..3279626 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 307baa6aeb434abe8962eb36d66b270cc9d15264 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:57:07 +0000 Subject: [PATCH 032/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 3c3f96a..3fc2051 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", "@stdlib/strided-base-reinterpret-complex64": "^0.0.2", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From ae8a621cfffe67ab96e876fe85f3a9ad2ab1c91d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 02:04:11 +0000 Subject: [PATCH 033/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 0521bde..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2601140..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("01B2k",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 77806b6..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '01B2k', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3279626..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c631146f557909ae75fb24b6461d92dc0373770e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 02:05:02 +0000 Subject: [PATCH 034/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1451 ----- 50 files changed, 6209 insertions(+), 6459 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.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/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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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' - 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 - - # 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' }} - 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@v2 - 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 + + ```
@@ -238,7 +231,7 @@ console.log( arr ); ## 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]. @@ -304,23 +297,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd863c6..5245246 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7c2efef --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..009087e --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 3fc2051..12f7a51 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.6", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-complex-typed-array": "^0.0.6", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..1b0a124 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From c1dd0207a08ea139359b1902b927d91324be12da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:03:28 +0000 Subject: [PATCH 035/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index bd0d26d..0dd10e7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.0", "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", "@stdlib/strided-base-reinterpret-complex64": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 7350819d7a90a1b1a286f340e413161a53e2e2cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:30:04 +0000 Subject: [PATCH 036/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 5245246..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7c2efef..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 009087e..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;seA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1b0a124..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 53845d3c3b1cdf037e563ac78bb71cd604b7e11e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:32:18 +0000 Subject: [PATCH 037/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1451 ----- 51 files changed, 6209 insertions(+), 6494 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 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.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/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 070ca0e..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/typed) 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 f3c751c..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/typed) 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 eb274e3..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: '10 10 * * 1' - - # 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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' - 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 - - # 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' }} - 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@v2 - 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 + + ```
@@ -249,7 +242,7 @@ console.log( arr ); ## 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]. @@ -315,23 +308,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd863c6..5245246 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdf0b80 --- /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@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bfdf91d --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2fA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 0dd10e7..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.0.6", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.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.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", - "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..6e87c27 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f35c32e67dea7d6fc239e8d0f9a9c6d40f268b14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:42:14 +0000 Subject: [PATCH 038/138] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f63b2eb..6898054 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs'; +import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.1.0-esm/index.mjs'; ``` #### typedarray( \[dtype] ) @@ -184,7 +184,7 @@ var arr6 = typedarray( buf, 10, 4, 'int16' ); - - - - From bcd619ac56494692495726304f665b876ffb3b8b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 01:37:22 +0000 Subject: [PATCH 042/138] Auto-generated commit --- .editorconfig | 186 - .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 | 247 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1451 ----- test/test.js | 1451 ----- 53 files changed, 6209 insertions(+), 8004 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 a08c7d8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:17:34.735Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -249,7 +242,7 @@ console.log( arr ); ## 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]. @@ -315,23 +308,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd863c6..5245246 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e0f02f0 --- /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@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 52d062d..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.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.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..e834b18 --- /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 7b21c85..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 21d641228faa843e4bd3a5bda3dc2371d5afa6c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 19:41:56 +0000 Subject: [PATCH 043/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 140a864..0cd355c 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", "@stdlib/strided-base-reinterpret-complex64": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 0553fd13beb8ed912061e7b8fed924bc8a761083 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:35:08 +0000 Subject: [PATCH 044/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 5245246..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e0f02f0..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@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e834b18..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eff7e622599b08dbb02214e704714b57498a2c84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:38:37 +0000 Subject: [PATCH 045/138] Auto-generated commit --- .editorconfig | 186 - .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 | 247 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1451 ----- test/test.js | 1451 ----- 52 files changed, 6209 insertions(+), 8003 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -249,7 +242,7 @@ console.log( arr ); ## 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]. @@ -315,23 +308,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd863c6..5245246 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c4476ca --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 0cd355c..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.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.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..5591c28 --- /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 7b21c85..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 6a57d4285e1fcdd273c6088806148930a3e1fdcc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:22:27 +0000 Subject: [PATCH 046/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 74fff7b..727681b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 0b3264bac8b62eb9c56bee72204f7f91a18a2d42 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:44:40 +0000 Subject: [PATCH 047/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 5245246..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c4476ca..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5591c28..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5902e33d3e346076053008bfd17118d148fa3f03 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:47:16 +0000 Subject: [PATCH 048/138] Auto-generated commit --- .editorconfig | 186 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6209 insertions(+), 6594 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 bfec25c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:37:11.423Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -249,7 +242,7 @@ console.log( arr ); ## 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]. @@ -315,23 +308,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd863c6..5245246 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9e18648 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 727681b..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..ce3e064 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 817f4642eb6d323d9cec2cf72eb5b1b30c6d0039 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 12:58:54 +0000 Subject: [PATCH 049/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 74fff7b..727681b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From cc1b67f89aa05ea387e5860fd6a9ee2fa9ab3344 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 17:36:18 +0000 Subject: [PATCH 050/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 5245246..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e18648..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ce3e064..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 85f8b8fa926c10ef7b47adf84ffc6b2c86bb63b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 17:38:46 +0000 Subject: [PATCH 051/138] Auto-generated commit --- .editorconfig | 186 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 52 files changed, 6209 insertions(+), 6593 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -249,7 +242,7 @@ console.log( arr ); ## 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]. @@ -315,23 +308,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 06a13f2..3e585fc 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9e18648 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 727681b..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..7d5e289 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f3cb718a577eca6f01eb3a43518f639e78069914 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 10:13:59 +0000 Subject: [PATCH 052/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 1c3c564..3b4f0a4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From a6fab8bb86366fccb939b450376e924d58970730 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:02:05 +0000 Subject: [PATCH 053/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 3e585fc..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e18648..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7d5e289..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a6befb83f6bcfe8adc554a13209e409d3efd0aed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:04:45 +0000 Subject: [PATCH 054/138] Auto-generated commit --- .editorconfig | 186 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 52 files changed, 6211 insertions(+), 6595 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 06a13f2..3e585fc 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // tslint:disable:unified-signatures -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9e18648 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 3b4f0a4..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..0b53fc0 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From e087bfb40807cbc3614d995a191bffff9e3fe033 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:29:30 +0000 Subject: [PATCH 055/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 1c3c564..3b4f0a4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 350d09ab51a2791f3d97129e49a70d325ed6b26c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:46:25 +0000 Subject: [PATCH 056/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 3e585fc..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// tslint:disable:unified-signatures - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e18648..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b53fc0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bf65a082c7592691900c13a2492ddac806e4209a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:49:09 +0000 Subject: [PATCH 057/138] Auto-generated commit --- .editorconfig | 186 - .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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 52 files changed, 6211 insertions(+), 6595 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 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.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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 - -# 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 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 1c7e0f5..4efcbfb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9e18648 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 3b4f0a4..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..f1452a7 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f489e6adf20ef2a418021a32752c837aa49040f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:32:45 +0000 Subject: [PATCH 058/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 5075b10..08b6084 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -132,7 +132,7 @@ function typedarray() { } 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( '02N2Y,KZ', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 3b22aac..8101f80 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 819ff2dd548580657d6a9598b8bf12cfc566ea34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:34:02 +0000 Subject: [PATCH 059/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 4efcbfb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e18648..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f1452a7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0e3f624b73dbc920aaa937fc3267c0c201349bfc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:36:57 +0000 Subject: [PATCH 060/138] 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 | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6211 insertions(+), 6591 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 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.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 9907d4f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:42:34.491Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 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 f234831..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/typed) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 7354d1e..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: '10 10 * * 1' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # 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 corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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 - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - 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: 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' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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' - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # 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: 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a98b7ba..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 15ff04f..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7eb2a58..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 33ed995..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 ad5dbac..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index a4b89d1..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 75d410d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 1b98556..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 546deba..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 513c442..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 5401c40..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 823af0e..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 1c7e0f5..4efcbfb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9e18648 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..81c06c0 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 08b6084..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y,KZ', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 8101f80..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..6e19aed --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 0c1298afb00feb69954b3772e39e8eef83b1f012 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 Dec 2023 11:03:44 +0000 Subject: [PATCH 061/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e46922..d6f4e08 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 4a4231125d75c96b1ddd1740220de5d4ce927645 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 Dec 2023 11:12:52 +0000 Subject: [PATCH 062/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 4efcbfb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, RealOrComplexDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: RealOrComplexDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e18648..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("02N2Y,KZ",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 81c06c0..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y,KZ', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;kgBA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6e19aed..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 407574975d2dbb51837ee800d2e4c41b370c7c9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 Dec 2023 11:13:22 +0000 Subject: [PATCH 063/138] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6211 insertions(+), 6596 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 749352a..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: '10 10 * * 1' - - # 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 af5b6c1..ad70baf 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3c5eb76 --- /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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9910378 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 5075b10..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index d6f4e08..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..2053a17 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From e2cfb88513ae6ede5c5125d9753ca841887e9195 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:03:36 +0000 Subject: [PATCH 064/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e46922..d6f4e08 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 835d2b361d4efc29fd2e3292ad382d6940d5283e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:40:28 +0000 Subject: [PATCH 065/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 ad70baf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3c5eb76..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@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9910378..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2053a17..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8b67b5769490527e0c0a00dd8f391584264f4a4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:40:52 +0000 Subject: [PATCH 066/138] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 54 files changed, 6211 insertions(+), 6597 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.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 0de518e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:11:44.991Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 749352a..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: '10 10 * * 1' - - # 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 af5b6c1..ad70baf 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ddb2214 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9910378 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 5075b10..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index d6f4e08..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..c944172 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 09d9abb9c7e53e56ba88062960062e66bfe93867 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:19:51 +0000 Subject: [PATCH 067/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e46922..d6f4e08 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 1bd7b0650a44e4143c740f2d384c9867bd1c2ab2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:41:17 +0000 Subject: [PATCH 068/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 ad70baf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ddb2214..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9910378..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c944172..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 19831a2dcd3404d361954a2d67c830504f91d45d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:41:38 +0000 Subject: [PATCH 069/138] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 160 - package.json | 73 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6211 insertions(+), 6596 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 749352a..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: '10 10 * * 1' - - # 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c98d209..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(d,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),o=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),p=n("complex64"),f=n("complex128");function l(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e="float64",a=n(e),a===null)throw new TypeError(v('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof p?t=g(t,0):t instanceof f&&(t=o(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=l -});var c=u();module.exports=c; -/** @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 6905b48..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAS,QAAS,uBAAwB,EAK1CC,EAAiBJ,EAAO,WAAY,EACpCK,EAAkBL,EAAO,YAAa,EAuF1C,SAASM,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASR,EAAU,UAAWQ,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQ,UAETC,EAAOT,EAAOQ,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWN,EAAQ,sEAAuEK,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMR,EAAeQ,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMT,EAAgBS,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAX,EAAO,QAAUQ,ICvCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "format", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 6a2d4da..ed663a4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ddb2214 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9910378 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 5075b10..0000000 --- a/lib/main.js +++ /dev/null @@ -1,160 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index d6f4e08..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..fa002bb --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f4d8f41b09ebf11d06a7df627c51753bb4e70e4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:39:55 +0000 Subject: [PATCH 070/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ba9b3b..735e6d6 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From a5124cd2cf59a8be7cd6f6a41092c03eb9736c71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:42:02 +0000 Subject: [PATCH 071/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 ed663a4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ddb2214..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var i=t("complex64"),d=t("complex128");function m(){var m,o,l,p;if(o=(m=arguments.length)&&e(arguments[m-1])?arguments[m-=1]:"float64",null===(l=t(o)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",o));return m<=0?new l(0):1===m?((p=arguments[0])instanceof i?p=r(p,0):p instanceof d&&(p=s(p,0)),new l(p)):2===m?new l(arguments[0],arguments[1]):new l(arguments[0],arguments[1],arguments[2])}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9910378..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;yfA+BA,IAAIA,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGD,UAGK,QADdE,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fa002bb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7fd18bd6c15434989b1a6e3d30bd709be52f5937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:42:24 +0000 Subject: [PATCH 072/138] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6211 insertions(+), 6599 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 749352a..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: '10 10 * * 1' - - # 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 + + ```
@@ -251,7 +244,7 @@ console.log( arr ); ## 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]. @@ -317,27 +310,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 6ba4377..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[esm-url]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 6a2d4da..ed663a4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..85ec35d --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var d=i.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var i,l,p,a;if(l=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:d,null===(p=t(l)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",l));return i<=0?new p(0):1===i?((a=arguments[0])instanceof m?a=r(a,0):a instanceof o&&(a=s(a,0)),new p(a)):2===i?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2d42460 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;klBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 ebb84b9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 735e6d6..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.1.0", - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..4e8a014 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 122a726bf3c80f0e67d36751b562719d8891eaa4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:37:09 +0000 Subject: [PATCH 073/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ba9b3b..735e6d6 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 738c1366c6dc6d801f81f8e5e3137f7ea5da91c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:58:48 +0000 Subject: [PATCH 074/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 ed663a4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 85ec35d..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var d=i.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var i,l,p,a;if(l=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:d,null===(p=t(l)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",l));return i<=0?new p(0):1===i?((a=arguments[0])instanceof m?a=r(a,0):a instanceof o&&(a=s(a,0)),new p(a)):2===i?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2d42460..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;klBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4e8a014..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 80ca40c36886174c985f264b4abbdb725da09867 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:59:21 +0000 Subject: [PATCH 075/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 54 files changed, 6211 insertions(+), 6605 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.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 00a87fb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:01:48.344Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 749352a..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 6a2d4da..ed663a4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..85ec35d --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var d=i.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var i,l,p,a;if(l=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:d,null===(p=t(l)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",l));return i<=0?new p(0):1===i?((a=arguments[0])instanceof m?a=r(a,0):a instanceof o&&(a=s(a,0)),new p(a)):2===i?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2d42460 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;klBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 ebb84b9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 735e6d6..7ba31de 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a typed 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.1.0", - "@stdlib/array-typed-ctors": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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..d01bbe4 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 03cad885968c9de96e1d46ae041fc7e5b1367003 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:20:32 +0000 Subject: [PATCH 076/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 252fffb..4c6902a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.2.0", "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From b286615903cde9d5a4c8d83fd3e44cbebed22a7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 03:10:46 +0000 Subject: [PATCH 077/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6362 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 ed663a4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 85ec35d..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var d=i.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var i,l,p,a;if(l=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:d,null===(p=t(l)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",l));return i<=0?new p(0):1===i?((a=arguments[0])instanceof m?a=r(a,0):a instanceof o&&(a=s(a,0)),new p(a)):2===i?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2d42460..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;klBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d01bbe4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f5e51b32965369e89471986790b2f348f1107b11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 03:11:38 +0000 Subject: [PATCH 078/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ----- 53 files changed, 6211 insertions(+), 6608 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 fe89096..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1974fca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 6a2d4da..ed663a4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22d3752 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var d=i.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var i,l,p,a;if(l=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:d,null===(p=t(l)))throw new TypeError(n("invalid argument. Must provide a recognized data type. Value: `%s`.",l));return i<=0?new p(0):1===i?((a=arguments[0])instanceof m?a=r(a,0):a instanceof o&&(a=s(a,0)),new p(a)):2===i?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2d42460 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;klBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,sEAAuEP,IAErG,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 ebb84b9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } 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 ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 4c6902a..73b9abe 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a typed 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.0", - "@stdlib/array-typed-ctors": "^0.2.0", - "@stdlib/assert-is-string": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.0", - "@stdlib/assert-is-typed-array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-base-randu": "^0.1.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..9dd7f51 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From b0d2bcf890c7fafdf99916de95d7b94ca5fff64e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:52:47 +0000 Subject: [PATCH 079/138] 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 bd46855..5a74f0b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs'; +import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.2.0-esm/index.mjs'; ``` #### typedarray( \[dtype] ) @@ -184,7 +184,7 @@ var arr6 = typedarray( buf, 10, 4, 'int16' ); - - - - From 98a8b8716c0bd9a329e9113e00c7c9f23af7990e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:51:00 +0000 Subject: [PATCH 083/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ------ 53 files changed, 4876 insertions(+), 6602 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a073089 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..741a3d7 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 4c00dcf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 2163077..73b9abe 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a typed 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.0", - "@stdlib/array-typed-ctors": "^0.2.0", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.0", - "@stdlib/assert-is-typed-array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.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..af0eef7 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From a32461a091c0d6982077c04f613dce20c59e1581 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:11:04 +0000 Subject: [PATCH 084/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index ebb84b9..4c00dcf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -134,7 +134,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 8de413c..bdb0cab 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From fed9f39af4995703cfafad6ba01c5b4b870e46de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:56:55 +0000 Subject: [PATCH 085/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a073089..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 741a3d7..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index af0eef7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b7390cb5faaea3e9002295f6717e771c814ca54c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:58:25 +0000 Subject: [PATCH 086/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ------ 53 files changed, 4876 insertions(+), 6603 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2b8d4de --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..741a3d7 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 4c00dcf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index bdb0cab..34e2838 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a typed 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.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..d603fc0 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From df8fdadf21eccc16b3af17ac7da2c399bcaff128 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:33:28 +0000 Subject: [PATCH 087/138] 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 2c84ca5..567e258 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs'; +import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.2.1-esm/index.mjs'; ``` #### typedarray( \[dtype] ) @@ -184,7 +184,7 @@ var arr6 = typedarray( buf, 10, 4, 'int16' ); - - - - From 9995175353abaf9c776931ccd19fb55ac4fb387e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:39:43 +0000 Subject: [PATCH 091/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ------ 54 files changed, 4876 insertions(+), 6605 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.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 70b8d3b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:43:31.451Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0853673 --- /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@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b489f1e --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;ijBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 4c00dcf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 65616e5..34e2838 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a typed 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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..e414f4c --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 82107fb3893f2e5b1820cccf743d3c2dd12cfc5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:13:41 +0000 Subject: [PATCH 092/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index ebb84b9..4c00dcf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -134,7 +134,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index e2936a7..65616e5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From d7590324a2982591cce72a47910a49ac596302de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:35:49 +0000 Subject: [PATCH 093/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0853673..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@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b489f1e..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;ijBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e414f4c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d0e254e5e5106af0bf7e77aab7038267755572e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:36:03 +0000 Subject: [PATCH 094/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ------ 54 files changed, 4876 insertions(+), 6608 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.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 dcf6c1a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:01:29.475Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8c21e7c --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..741a3d7 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 4c00dcf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 65616e5..34e2838 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a typed 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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..858ec70 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From eea3f3f2c011498046c1b1d1c3a5a68dbda4e54f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:31:04 +0000 Subject: [PATCH 095/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index ebb84b9..4c00dcf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ctors = require( '@stdlib/array-typed-ctors' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -134,7 +134,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index e2936a7..65616e5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 28352181499cfbf74a82ccc88ee6f9b8ce31cc66 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:51:55 +0000 Subject: [PATCH 096/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8c21e7c..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 741a3d7..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 858ec70..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 446b7fef88106d6680365404d4a1f4518e4064c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:52:13 +0000 Subject: [PATCH 097/138] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 246 -- benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 141 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 162 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1451 ------ 53 files changed, 4876 insertions(+), 6609 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -253,7 +244,7 @@ console.log( arr ); ## 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]. @@ -322,27 +313,27 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 69da678..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,246 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fddf8fe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,i){ -var m=require('@stdlib/assert-is-string/dist').isPrimitive,n=require('@stdlib/array-typed-ctors/dist'),v=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/strided-base-reinterpret-complex64/dist'),o=require('@stdlib/array-defaults/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),f=o.get("dtypes.default"),l=n("complex64"),c=n("complex128");function d(){var r,e,a,t;if(r=arguments.length,r&&m(arguments[r-1])?(r-=1,e=arguments[r]):e=f,a=n(e),a===null)throw new TypeError(p('02N2Y',e));return r<=0?new a(0):r===1?(t=arguments[0],t instanceof l?t=g(t,0):t instanceof c&&(t=v(t,0)),new a(t)):r===2?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}i.exports=d -});var y=u();module.exports=y; -/** @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 2bd9497..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) 2018 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 ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBN,EAAO,WAAY,EACpCO,EAAkBP,EAAO,YAAa,EAuF1C,SAASQ,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASV,EAAU,UAAWU,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQL,EAETM,EAAOX,EAAOU,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWP,EAAQ,sEAAuEM,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeN,EACnBM,EAAMV,EAAeU,EAAK,CAAE,EACjBA,aAAeL,IAC1BK,EAAMX,EAAgBW,EAAK,CAAE,GAEvB,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAb,EAAO,QAAUU,ICzCjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ae4ee84..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,141 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed 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 - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8c21e7c --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..741a3d7 --- /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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 4c00dcf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,162 +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 isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 65616e5..34e2838 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a typed 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-complex-typed-array": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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..858ec70 --- /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 5bd04be..0000000 --- a/test/test.js +++ /dev/null @@ -1,1451 +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 tape = require( 'tape' ); -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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 4c04790a011218f76546e447f7b3cb92b58998ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Jun 2024 20:19:00 +0000 Subject: [PATCH 098/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index e3d7dd1..b49eb0f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.1", "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 2d470c35a690d4b136b3cbada3067be80253055a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Jun 2024 20:19:24 +0000 Subject: [PATCH 099/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8c21e7c..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var i=n.get("dtypes.default"),m=t("complex64"),o=t("complex128");function l(){var n,l,p,j;if(l=(n=arguments.length)&&e(arguments[n-1])?arguments[n-=1]:i,null===(p=t(l)))throw new TypeError(d("02N2Y",l));return n<=0?new p(0):1===n?((j=arguments[0])instanceof m?j=r(j,0):j instanceof o&&(j=s(j,0)),new p(j)):2===n?new p(arguments[0],arguments[1]):new p(arguments[0],arguments[1],arguments[2])}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 741a3d7..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) 2018 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 ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128"],"mappings":";;2lBAgCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cAuF7B,SAASE,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDP,EAGK,QADdS,EAAOL,EAAOI,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGR,EACnBO,EAAMM,EAAeN,EAAK,GACfA,aAAeL,IAC1BK,EAAMO,EAAgBP,EAAK,IAErB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 858ec70..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6ab57cda059187c7b7534a171d26343ee4a575bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Jun 2024 20:19:56 +0000 Subject: [PATCH 100/138] 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 | 124 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 54 files changed, 4877 insertions(+), 6978 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f1adda9 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index b49eb0f..34e2838 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.1", - "@stdlib/assert-is-complex-typed-array": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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..9365f78 --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 38dd3781a06f0cdd015b4b19a5f9c1391eab8a9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:49:55 +0000 Subject: [PATCH 101/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 52a7dfb..534adbe 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7e7b6885be1e86422a89b5d96d184e812b38eb8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:09:56 +0000 Subject: [PATCH 102/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f1adda9..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9365f78..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 191db89ac50be2e511396c213dfacbb97f0a1b13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:10:15 +0000 Subject: [PATCH 103/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 277 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 54 files changed, 4877 insertions(+), 7133 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.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 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..66c157e --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 534adbe..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@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-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-booleanarray": "^0.0.1", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..049baa3 --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 8206633bc25527a82ca7da10eef3ae2ac10e9524 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:21:55 +0000 Subject: [PATCH 104/138] 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 83a6d99..74e0fb3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs'; +import typedarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs'; ``` #### typedarray( \[dtype] ) @@ -170,7 +170,7 @@ var arr6 = typedarray( buf, 10, 4, 'int16' ); - - - - From ecef9263c02952c36d3bc8fb5a8367252fec85f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 12:56:14 +0000 Subject: [PATCH 108/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 138 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 55 files changed, 4877 insertions(+), 6995 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.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.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/.keepalive b/.github/.keepalive deleted file mode 100644 index 5810bc2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T05:54:00.809Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b6b9571 --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 88aa6c4..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f43f48b79dd9f3f8e87b6148126493b96fe7189d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:26:41 +0000 Subject: [PATCH 109/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 65330bf..05a3dad 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 964cbc65246b4721901458bb394bd926ae1b7133 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:51:25 +0000 Subject: [PATCH 110/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b6b9571..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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a060e3dc6530243eb35f6b630a49b4c1443455e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:51:43 +0000 Subject: [PATCH 111/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 55 files changed, 4877 insertions(+), 7132 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.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.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/.keepalive b/.github/.keepalive deleted file mode 100644 index 56bdbdb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:20:51.891Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b6b9571 --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 05a3dad..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f606be995cddb7368517371f820818d429330e5c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:44:20 +0000 Subject: [PATCH 112/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 65330bf..05a3dad 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 5dc3037e486b582904485a1fc869ce044d91915e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:26:14 +0000 Subject: [PATCH 113/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b6b9571..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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 59ceed72dac7c6966448e69f4f6801c7c7446cf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:26:33 +0000 Subject: [PATCH 114/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 55 files changed, 4877 insertions(+), 7132 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.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.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/.keepalive b/.github/.keepalive deleted file mode 100644 index bdf6950..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T06:32:58.685Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b6b9571 --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 05a3dad..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From c7dbbbb03baaca92b7dc6d0780c24239ee181c93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:30:14 +0000 Subject: [PATCH 115/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 65330bf..05a3dad 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From a12dfb55e3a1cfa783f281ebc47b7732547615e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:28:05 +0000 Subject: [PATCH 116/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b6b9571..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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fe41330501ec1d2868ac4dac14c048f906c60c20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:28:27 +0000 Subject: [PATCH 117/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------- 55 files changed, 4877 insertions(+), 7132 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.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.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/.keepalive b/.github/.keepalive deleted file mode 100644 index b35fb4a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T06:36:10.449Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b6b9571 --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 05a3dad..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f549ed3c6ca8acc04841ce5260f92ce573a1e618 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:23:49 +0000 Subject: [PATCH 118/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 6bb408644571668108354cae9f5a1d676a3508fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:39:32 +0000 Subject: [PATCH 119/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b6b9571..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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e60a7bc5a28c156e0ebd3f43ef82b5adc4ff2d3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:39:56 +0000 Subject: [PATCH 120/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------ 56 files changed, 4877 insertions(+), 7237 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.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 0779e8a..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 = 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 fa5c36b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:54:01.359Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 070ca0e..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b6b9571 --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From f3737fd5ceab2a23c051bdaceb9f104db82416c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 00:37:47 +0000 Subject: [PATCH 121/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From d3f1cefa74877de3a7c36de2997e7a6ce2389bf5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 00:39:46 +0000 Subject: [PATCH 122/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b6b9571..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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From be1a51e0b1a14e282c4989ab67e0d35e29c3e16c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 00:40:02 +0000 Subject: [PATCH 123/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------ 56 files changed, 4877 insertions(+), 7240 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.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 671aec6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T00:36:49.367Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From a40490d1cb9a973a9b64227b0edf4f58b8fa5172 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:51:15 +0000 Subject: [PATCH 124/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 12b3187448adf9d67894825aee7b3879114abf72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:54:47 +0000 Subject: [PATCH 125/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0bbec6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 800d94c90948107196168e5b91e6fdd49f1e5452 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:55:14 +0000 Subject: [PATCH 126/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 275 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 45 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------ 56 files changed, 4877 insertions(+), 7240 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.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 b333402..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T00:48:32.088Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 08c9fb1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - typedarray(); // $ExpectType Float64Array - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 cd4fc63..a3d73d5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 8532c0eac354c95fc97bd2c96c340988b281af65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 03:06:10 +0000 Subject: [PATCH 127/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From e428943d1dbf92e973179a9216719a023442726a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 03:06:30 +0000 Subject: [PATCH 128/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 a3d73d5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0bbec6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b726c4b3dd8acf80a3ec61d0f4b6c7006d57c450 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 03:07:18 +0000 Subject: [PATCH 129/138] 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 | 309 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 51 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------ 55 files changed, 4877 insertions(+), 7279 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.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 b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 57ae089..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array2iterator = require( '@stdlib/array-to-iterator' ); -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array... -{ - typedarray(); // $ExpectType Float64Array - typedarray( [ 1, 2, 3 ] ); // $ExpectType Float64Array - typedarray( array2iterator( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array - typedarray( new ArrayBuffer( 10 ) ); // $ExpectType Float64Array - - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 f9b1b83..fcfcce5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; import { Iterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From b024b4b85e857d9fb80dcaf1b592a64c56799069 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 18:07:26 +0000 Subject: [PATCH 130/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 543774ba4f4c6688536f95e11f5ce2c93a80ef19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 18:07:48 +0000 Subject: [PATCH 131/138] Remove files --- index.d.ts | 181 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5028 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 fcfcce5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,181 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; -import { Iterator } from '@stdlib/types/iter'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: Collection | Iterator, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0bbec6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c144eab403f22422ceb1dc6ddfca937da8da6fba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 18:08:15 +0000 Subject: [PATCH 132/138] 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 | 320 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 49 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1555 ------ 55 files changed, 4877 insertions(+), 7288 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.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 b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b446604..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -import typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array... -{ - typedarray(); // $ExpectType Float64Array - typedarray( [ 1, 2, 3 ] ); // $ExpectType Float64Array - typedarray( new ArrayBuffer( 10 ) ); // $ExpectType Float64Array - - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 72d4d06..243f770 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 02ff3cc..0000000 --- a/test/test.js +++ /dev/null @@ -1,1555 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From 6232c9556157beb6d0b849732ed7eb87607db713 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 11:58:34 +0000 Subject: [PATCH 133/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From a2376903f051ebaf52c870f9ba132f48f0f0ede8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 11:58:57 +0000 Subject: [PATCH 134/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 243f770..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: Collection | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0bbec6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cadbd5389feda55546761df053bd4029999f3c47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 11:59:45 +0000 Subject: [PATCH 135/138] 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 | 321 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 49 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1575 ------ 55 files changed, 4877 insertions(+), 7309 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.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 b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b446604..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -import typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array... -{ - typedarray(); // $ExpectType Float64Array - typedarray( [ 1, 2, 3 ] ); // $ExpectType Float64Array - typedarray( new ArrayBuffer( 10 ) ); // $ExpectType Float64Array - - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 72d4d06..243f770 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 5f0663c..0000000 --- a/test/test.js +++ /dev/null @@ -1,1575 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); From b21047275c70def21daf0bb97e51c32108f4e2ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 00:54:56 +0000 Subject: [PATCH 136/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0bf4b65..df83a81 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -136,7 +136,7 @@ function typedarray() { } 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( '02N2Y', dtype ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); diff --git a/package.json b/package.json index 0ec5c77..10bff9f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From b4ba91033ff90434a783f206b4200603a55a8764 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:10:45 +0000 Subject: [PATCH 137/138] Remove files --- index.d.ts | 180 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5027 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 243f770..0000000 --- a/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: Collection | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0bbec6b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d880d43..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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a56f17e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d4d518f5e6fb8f8d4f559385e9258506af5be811 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:11:12 +0000 Subject: [PATCH 138/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 321 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 265 - benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 93 - benchmark/benchmark.length.complex64.js | 93 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.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 | 36 - dist/index.js.map | 7 - docs/repl.txt | 125 - docs/types/test.ts | 49 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 126 - lib/main.js | 166 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1575 ------ 56 files changed, 4877 insertions(+), 7310 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.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 d433d20..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T00:52:07.192Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b5b0e76..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/typed) 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 f234831..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/typed) 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 7054dbf..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: '10 10 * * 1' - - # 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 + + ```
@@ -239,7 +230,7 @@ console.log( arr ); ## 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]. @@ -306,31 +297,31 @@ 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/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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 6541d51..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex 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 = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean 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 = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( 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 = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed 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 87d030c..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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9db9be7..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ff557f1..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isComplexTypedArray = require( '@stdlib/assert-is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 49fccc6..0000000 --- a/benchmark/benchmark.length.float32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 29ee981..0000000 --- a/benchmark/benchmark.length.float64.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6c6b400..0000000 --- a/benchmark/benchmark.length.int16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 3978557..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 306ca8d..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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 376f38a..0000000 --- a/benchmark/benchmark.length.uint16.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 139ffea..0000000 --- a/benchmark/benchmark.length.uint32.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 16c7c50..0000000 --- a/benchmark/benchmark.length.uint8.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 06690e5..0000000 --- a/benchmark/benchmark.length.uint8c.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 typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 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 226db3c..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/typed" -%% click B href "https://github.com/stdlib-js/array-typed/tree/main" -%% click C href "https://github.com/stdlib-js/array-typed/tree/production" -%% click D href "https://github.com/stdlib-js/array-typed/tree/esm" -%% click E href "https://github.com/stdlib-js/array-typed/tree/deno" -%% click F href "https://github.com/stdlib-js/array-typed/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed -[production-url]: https://github.com/stdlib-js/array-typed/tree/production -[deno-url]: https://github.com/stdlib-js/array-typed/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-typed/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-typed/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-typed/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-typed/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-typed/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 53f64be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import typedarray from '../docs/types/index'; -export = typedarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b44a1ca..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var s=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var u=s(function(A,i){"use strict";var o=require("@stdlib/assert-is-string").isPrimitive,n=require("@stdlib/array-typed-ctors"),v=require("@stdlib/strided-base-reinterpret-complex128"),l=require("@stdlib/strided-base-reinterpret-complex64"),m=require("@stdlib/strided-base-reinterpret-boolean"),g=require("@stdlib/array-defaults"),f=require("@stdlib/string-format"),p=g.get("dtypes.default"),c=n("complex64"),d=n("complex128"),y=n("bool");function q(){var e,a,t,r;if(e=arguments.length,e&&o(arguments[e-1])?(e-=1,a=arguments[e]):a=p,t=n(a),t===null)throw new TypeError(f("invalid argument. Must provide a recognized data type. Value: `%s`.",a));return e<=0?new t(0):e===1?(r=arguments[0],r instanceof c?r=l(r,0):r instanceof d?r=v(r,0):r instanceof y&&(r=m(r,0)),new t(r)):e===2?new t(arguments[0],arguments[1]):new t(arguments[0],arguments[1],arguments[2])}i.exports=q});var w=u();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index eb4b65e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar ctors = require( '@stdlib/array-typed-ctors' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\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 ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = typedarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 typed array.\n*\n* @module @stdlib/array-typed\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var typedarray = require( '@stdlib/array-typed' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\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,EAAQ,QAAS,2BAA4B,EAC7CC,EAAiB,QAAS,6CAA8C,EACxEC,EAAgB,QAAS,4CAA6C,EACtEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAC/CG,EAAiBP,EAAO,WAAY,EACpCQ,EAAkBR,EAAO,YAAa,EACtCS,EAAeT,EAAO,MAAO,EAuFjC,SAASU,GAAa,CACrB,IAAIC,EACAC,EACAC,EACAC,EAUJ,GARAH,EAAQ,UAAU,OACbA,GAASZ,EAAU,UAAWY,EAAM,CAAE,CAAE,GAC5CA,GAAS,EACTC,EAAQ,UAAWD,CAAM,GAEzBC,EAAQN,EAETO,EAAOb,EAAOY,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWR,EAAQ,sEAAuEO,CAAM,CAAE,EAE7G,OAAKD,GAAS,EACN,IAAIE,EAAM,CAAE,EAEfF,IAAU,GACdG,EAAM,UAAW,CAAE,EAGdA,aAAeP,EACnBO,EAAMZ,EAAeY,EAAK,CAAE,EACjBA,aAAeN,EAC1BM,EAAMb,EAAgBa,EAAK,CAAE,EAClBA,aAAeL,IAC1BK,EAAMX,EAAoBW,EAAK,CAAE,GAE3B,IAAID,EAAMC,CAAI,GAEjBH,IAAU,EACP,IAAIE,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAEtC,IAAIA,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAC3D,CAKAf,EAAO,QAAUY,IC7CjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "ctors", "reinterpret128", "reinterpret64", "reinterpretBoolean", "defaults", "format", "DEFAULT_DTYPE", "Complex64Array", "Complex128Array", "BooleanArray", "typedarray", "nargs", "dtype", "ctor", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11b947d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b446604..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -import typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array... -{ - typedarray(); // $ExpectType Float64Array - typedarray( [ 1, 2, 3 ] ); // $ExpectType Float64Array - typedarray( new ArrayBuffer( 10 ) ); // $ExpectType Float64Array - - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 190c983..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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'; - -var randu = require( '@stdlib/random-base-randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -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 72d4d06..243f770 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array-buffer' ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0bbec6b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-ctors@v0.3.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var m=i.get("dtypes.default"),o=t("complex64"),l=t("complex128"),p=t("bool");function j(){var i,j,a,c;if(j=(i=arguments.length)&&e(arguments[i-1])?arguments[i-=1]:m,null===(a=t(j)))throw new TypeError(d("02N2Y",j));return i<=0?new a(0):1===i?((c=arguments[0])instanceof o?c=r(c,0):c instanceof l?c=s(c,0):c instanceof p&&(c=n(c,0)),new a(c)):2===i?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2])}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d880d43 --- /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) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport ctors from '@stdlib/array-typed-ctors';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\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* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '02N2Y', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n"],"names":["DEFAULT_DTYPE","defaults","get","Complex64Array","ctors","Complex128Array","BooleanArray","typedarray","nargs","dtype","ctor","arg","arguments","length","isString","TypeError","format","reinterpret64","reinterpret128","reinterpretBoolean"],"mappings":";;ssBAiCA,IAAIA,EAAgBC,EAASC,IAAK,kBAC9BC,EAAiBC,EAAO,aACxBC,EAAkBD,EAAO,cACzBE,EAAeF,EAAO,QAuF1B,SAASG,IACR,IAAIC,EACAC,EACAC,EACAC,EAUJ,GALCF,GAHDD,EAAQI,UAAUC,SACJC,EAAUF,UAAWJ,EAAM,IAEhCI,UADRJ,GAAS,GAGDR,EAGK,QADdU,EAAON,EAAOK,IAEb,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,OAAKD,GAAS,EACN,IAAIE,EAAM,GAEH,IAAVF,IACJG,EAAMC,UAAW,cAGGT,EACnBQ,EAAMM,EAAeN,EAAK,GACfA,aAAeN,EAC1BM,EAAMO,EAAgBP,EAAK,GAChBA,aAAeL,IAC1BK,EAAMQ,EAAoBR,EAAK,IAEzB,IAAID,EAAMC,IAEH,IAAVH,EACG,IAAIE,EAAME,UAAU,GAAIA,UAAU,IAEnC,IAAIF,EAAME,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b233ad7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,126 +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'; - -/** -* Create a typed array. -* -* @module @stdlib/array-typed -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array-typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var typedarray = require( '@stdlib/array-typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// 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 df83a81..0000000 --- a/lib/main.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var ctors = require( '@stdlib/array-typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @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 -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '02N2Y', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/package.json b/package.json index 10bff9f..78608e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a typed 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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-typed-ctors": "^0.3.0", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^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-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-booleanarray": "^0.0.2", - "@stdlib/assert-is-complex-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^0.2.1", - "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..a56f17e --- /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 5f0663c..0000000 --- a/test/test.js +++ /dev/null @@ -1,1575 +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 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 Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 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', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -});